package com.guowei.jiecloudbackstage.quickbooking.service.impl;

import com.guowei.jiecloudbackstage.common.api.vo.Result;
import com.guowei.jiecloudbackstage.quickbooking.entity.Order;
import com.guowei.jiecloudbackstage.quickbooking.mapper.OrderMapper;
import com.guowei.jiecloudbackstage.quickbooking.service.IOrderService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ym
 * @since 2021-07-06
 */
@Service
public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements IOrderService {

    @Autowired
    private OrderMapper orderMapper;

    /**
     * 查询全部订单信息
     * @return
     */
    @Override
    public Result getAll() {
        List<Order> list = new ArrayList<>();
        list = orderMapper.getAll();
        return Result.ok(200,list);
    }

    @Override
    public Result insertOrder(Order order) {
        int result = orderMapper.insertOrder(order);
        int result1 = orderMapper.insertRoomMsg(order);
        int result2 = orderMapper.insertGuest(order);
        if (result > 0){
            System.out.println("新增新订单成功！");
            return Result.ok(200,result);
        }else{
            System.out.println("新增订单信息失败！");
            return Result.error(513,"添加失败");
        }
    }
}
